<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>菜单管理</title>
		<%@ include file="/global/html-header.jsp"%>
		<script type="text/javascript">
	$(function() {
		$('.myform').idealforms();
		$("#myform").submit();
		common.validator("myform");
		common.initDialog("message-dialog");
		common.initDelDialogMsg("确定要删除此菜单？");
		
		$("#addMenu").on("click",function(){
			$("#addorupdate-dialog").wijdialog({ width: 700, height: 440, contentUrl: '/menu/menu-addorupdate.do?operationType=insert', autoOpen: true,modal : true,title:"新增菜单" });
		});
		
		$("#delete-dialog").wijdialog({
            autoOpen: false,
            resizable: false,
            height: 200,
            width: 320,
            modal: true,
            title:'删除部门',
            buttons: {
                "确定": function () {
                	if(!$("#delete-dialog").attr("operaterId")){
                		return false;
                	}
                	var delMenuId=$("#delete-dialog").attr("operaterId");
                	$.ajax({   
                		type: "POST",  
                		url: "/menu/menu-delete.do",  
                		data: ({"menu.menuId":delMenuId}), 
                		success: function(msg){    
                			if(msg=="success"){
                				$("#msgcontent").html("菜单删除成功！");
                				$("#queryResultIframe").contents().find("tr[menuId='"+delMenuId+"']'").remove();
                			}else if(msg="existchildmenu"){
                				$("#msgcontent").html("此菜单还存在子菜单，删除失败！");
                			}else{
                				$("#msgcontent").html("菜单删除失败！");
                			}
                			common.tipWithAutoClose("message-dialog");
                		} 
                	});
                    $(this).wijdialog("close");
                },
                "取消": function () {
                    $(this).wijdialog("close");
                }
            }
        });
	});
	//删除部门窗口弹出
	function deleteDivOpen(menuId){
		$('#delete-dialog').wijdialog('open');
		$('#delete-dialog').attr("operaterId",menuId);
	}
	
	function editMenuTip(msg){
		$("#msgcontent").html(msg);
		common.tipWithAutoClose("message-dialog");
	}
	
	function editDivOpen(menuId){
		$("#addorupdate-dialog").wijdialog({ width: 700, height: 440, contentUrl: '/menu/menu-addorupdate.do?operationType=update&menu.menuId='+menuId, autoOpen: true,modal : true,title:"编辑菜单" });
	}
	
	function closeDialog(){
		$("#message-dialog").wijdialog('close');
	}
	
	function closeOperatorDialog(){
		$("#message-dialog").wijdialog('close');
	}
	
	function editActionUriOperator(menuId){
		$("#message-dialog").wijdialog({ width: 700, height: 440, contentUrl: '/rbac/rbac-forward.do?operationType=menu&menu.menuId='+menuId, autoOpen: true,modal : true,title:"添加操作" });
	}
	
	function updateTitle(title){
		$("#ui-dialog-title-message-dialog").html(title);
	}
</script>
		<style>
			.ideal-form .ideal-wrap{clear: none;}
		</style>
	</head>
	<body>
		<div class="container">
			<div class="content">
				<form action="/menu/menu-query.do" name="myform" class="myform"
					id="myform" target="queryResultIframe" method="post">
					<%@ include file="menu-form.jsp" %>
				</form>
			</div>
			<div class="content hide" id="queryResult">
				<iframe class="queryResultIframe" name="queryResultIframe"
					id="queryResultIframe" src="about:blank" style="width: 90%;"
					frameborder="0" scrolling="no"></iframe>
			</div>
		</div>
		<%@ include file="/global/common-dialog.jsp" %>
	</body>
</html>